<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>编辑</title>
<meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="../../res/css/wholesale/font.css">
  	<link rel="stylesheet" href="../../res/css/wholesale/xadmin.css">
  	<link rel="stylesheet" href="../../res/layui/css/layui.css">
  	<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
 	<script type="text/javascript" src="../../res/layui/layui.js" charset="utf-8"></script>
  	<script type="text/javascript" src="../../res/js/wholesale/xadmin.js"></script>
</head>
<body>
	<form id="form" class="layui-form" action="../../listenBackstageUser/addOrUpdate.action" method="post" style="margin-top: 10px;">
		<input name="id" id='id' type="hidden">
		
		<div class="layui-form-item" style="width:70%;margin-left:41px;margin-top:20px;">
	    <label class="layui-form-label">用户姓名：</label>
		<div class="layui-input-block">
		      <input name="buName" id='buName' lay-verify="buName" autocomplete="off" placeholder="请输入用户姓名" class="layui-input" type="text">
		    </div>
	  	</div>
	  	
	  	<div class="layui-form-item" style="width:70%;margin-left:41px">
	    <label class="layui-form-label">用户密码：</label>
		<div class="layui-input-block">
		      <input name="buPwd" id='buPwd' lay-verify="buPwd" autocomplete="off" placeholder="请输入用户密码" class="layui-input" type="password">
		    </div>
	  	</div>
	  	
	  	<div class="layui-form-item" style="width:70%;margin-left:41px">
	    <label class="layui-form-label">用户电话：</label>
		<div class="layui-input-block">
		      <input name="buPhone" id='buPhone' lay-verify="buPhone" autocomplete="off" placeholder="请输入用户电话" class="layui-input" type="text">
		    </div>
	  	</div>
	  	
	  	<div class="layui-form-item" style="width:70%;margin-left:41px">
              <label class="layui-form-label">公司名称：</label>
              <div class="layui-input-block">
                  <select name="companyId" id="companyId" lay-verify="required" class="valid">
                  </select>
              </div>
         </div>
         
         <div class="layui-form-item" style="width:70%;margin-left:41px">
	    <label class="layui-form-label">备注：</label>
		<div class="layui-input-block">
		      <input name="buRemarks" id='buRemarks' lay-verify="buRemarks" autocomplete="off" placeholder="请输入备注" class="layui-input" type="text">
		    </div>
	  	</div>
	 <br/>
	  <div class="layui-form-item" style="width:70%;margin-left:45px">
	    <div class="layui-input-block">
	      <button class="layui-btn" lay-submit lay-filter="formDemo" id="sub">立即提交</button>
	    </div>
	   </div>
	</form>
<script>
layui.use(['form', 'layedit', 'laydate'], function(){
  var form = layui.form
  ,laydate = layui.laydate
  ,layer = layui.layer
  ,layedit = layui.layedit;
  
	//日期
  laydate.render({
	  elem:'#date'
   });
  
  //创建一个编辑器
  var editIndex = layedit.build('LAY_demo_editor');
 
  //自定义验证规则
  form.verify({
	buName: function(value){
	  if(value.indexOf(" ")>-1){
		return "用户姓名不能包含空格";
	  }else if(value.length < 1||value.length>7){
        return '长度至少得1个字符并且不能大于7个字符';
      }
    }
    ,buPwd: [
          /^[\S]{6,16}$/
          ,'密码必须6到16位，且不能出现空格'
     ]
    ,buPhone: [/^1[3|4|5|7|8]\d{9}$/, '手机必须11位，只能是数字！']
    ,buRemarks: function(value){
    	if(value.length>30){
    		return '长度不能大于30个字符';
    	}
    }
  });
  var url="../../listenCompany/queryAllzwm.action";
  var data=null;
  $.post(url,data,function(mes){
	  $.each(mes,function(index,item){
		  $("#companyId").append("<option></option><option value="+item.companyId+">"+item.companyName+"</option>");
		  form.render();
	  });
  },"json");

  //监听提交
  form.on('submit(formDemo)', function(data){
		  window.parent.location.reload();
		  var index=parent.layer.getFrameIndex(window.name);
		  parent.layer.close(index);
  });
 
 
  
});

function load(){
	var form = layui.form;
	form.render();
}
</script>
</body>
</html>